package com.jd.dict.run;

import com.jd.dict.config.ConfigClass;
import com.jd.dict.helper.DaoHelper;
import com.jd.dict.helper.DataDictHelper;
import com.jd.dict.helper.FileOperator;
import com.jd.dict.helper.TemplateHelper;
import com.jd.dict.model.TableInfoModel;

import java.util.List;

/**
 * Created by liuhaiming on 2017/7/28.
 */
public class Runner {
    public static void main(String[] args) {
        new Runner().run();
    }

    public void run() {
        try {
            List<TableInfoModel> tableList = DaoHelper.findAllTableInfo();

            // create table html
            for (TableInfoModel table : tableList) {
                DataDictHelper.createTableInfoFile(table);
            }

            // copy template
            String srcPath = FileOperator.getTemplatePath();
            FileOperator.copyFolder(srcPath, ConfigClass.OUT_PATH);

            // reverse template
            TemplateHelper.translateIndex();
            TemplateHelper.translateHeader();
            TemplateHelper.translateMenu(tableList);

            System.out.println("数据字典生成完毕！");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
